/**
 */
package ftldsl.impl;


import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import ftldsl.ComparisonOperator;
import ftldsl.Expression;
import ftldsl.FtldslPackage;
import ftldsl.FunctionCall;
import ftldsl.LogicalOperator;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Expression</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ftldsl.impl.ExpressionImpl#getValue <em>Value</em>}</li>
 *   <li>{@link ftldsl.impl.ExpressionImpl#getNext <em>Next</em>}</li>
 *   <li>{@link ftldsl.impl.ExpressionImpl#getLoperator <em>Loperator</em>}</li>
 *   <li>{@link ftldsl.impl.ExpressionImpl#getCoperator <em>Coperator</em>}</li>
 *   <li>{@link ftldsl.impl.ExpressionImpl#getInvocation <em>Invocation</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ExpressionImpl extends EObjectImpl implements Expression {
	/**
	 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected static final Object VALUE_EDEFAULT = null;
	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected Object value = VALUE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getNext() <em>Next</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNext()
	 * @generated
	 * @ordered
	 */
	protected Expression next;

	/**
	 * The default value of the '{@link #getLoperator() <em>Loperator</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoperator()
	 * @generated
	 * @ordered
	 */
	protected static final LogicalOperator LOPERATOR_EDEFAULT = LogicalOperator.XOR;
	/**
	 * The cached value of the '{@link #getLoperator() <em>Loperator</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoperator()
	 * @generated
	 * @ordered
	 */
	protected LogicalOperator loperator = LOPERATOR_EDEFAULT;
	/**
	 * The default value of the '{@link #getCoperator() <em>Coperator</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCoperator()
	 * @generated
	 * @ordered
	 */
	protected static final ComparisonOperator COPERATOR_EDEFAULT = ComparisonOperator.NOT;
	/**
	 * The cached value of the '{@link #getCoperator() <em>Coperator</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCoperator()
	 * @generated
	 * @ordered
	 */
	protected ComparisonOperator coperator = COPERATOR_EDEFAULT;
	/**
	 * The cached value of the '{@link #getInvocation() <em>Invocation</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInvocation()
	 * @generated
	 * @ordered
	 */
	protected FunctionCall invocation;
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ExpressionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return FtldslPackage.Literals.EXPRESSION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object getValue() {
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValue(Object newValue) {
		Object oldValue = value;
		value = newValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, FtldslPackage.EXPRESSION__VALUE, oldValue, value));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression getNext() {
		return next;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetNext(Expression newNext, NotificationChain msgs) {
		Expression oldNext = next;
		next = newNext;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FtldslPackage.EXPRESSION__NEXT, oldNext, newNext);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNext(Expression newNext) {
		if (newNext != next) {
			NotificationChain msgs = null;
			if (next != null)
				msgs = ((InternalEObject)next).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FtldslPackage.EXPRESSION__NEXT, null, msgs);
			if (newNext != null)
				msgs = ((InternalEObject)newNext).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - FtldslPackage.EXPRESSION__NEXT, null, msgs);
			msgs = basicSetNext(newNext, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, FtldslPackage.EXPRESSION__NEXT, newNext, newNext));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public LogicalOperator getLoperator() {
		return loperator;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLoperator(LogicalOperator newLoperator) {
		LogicalOperator oldLoperator = loperator;
		loperator = newLoperator == null ? LOPERATOR_EDEFAULT : newLoperator;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, FtldslPackage.EXPRESSION__LOPERATOR, oldLoperator, loperator));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComparisonOperator getCoperator() {
		return coperator;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCoperator(ComparisonOperator newCoperator) {
		ComparisonOperator oldCoperator = coperator;
		coperator = newCoperator == null ? COPERATOR_EDEFAULT : newCoperator;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, FtldslPackage.EXPRESSION__COPERATOR, oldCoperator, coperator));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FunctionCall getInvocation() {
		return invocation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetInvocation(FunctionCall newInvocation, NotificationChain msgs) {
		FunctionCall oldInvocation = invocation;
		invocation = newInvocation;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FtldslPackage.EXPRESSION__INVOCATION, oldInvocation, newInvocation);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInvocation(FunctionCall newInvocation) {
		if (newInvocation != invocation) {
			NotificationChain msgs = null;
			if (invocation != null)
				msgs = ((InternalEObject)invocation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FtldslPackage.EXPRESSION__INVOCATION, null, msgs);
			if (newInvocation != null)
				msgs = ((InternalEObject)newInvocation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - FtldslPackage.EXPRESSION__INVOCATION, null, msgs);
			msgs = basicSetInvocation(newInvocation, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, FtldslPackage.EXPRESSION__INVOCATION, newInvocation, newInvocation));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case FtldslPackage.EXPRESSION__NEXT:
				return basicSetNext(null, msgs);
			case FtldslPackage.EXPRESSION__INVOCATION:
				return basicSetInvocation(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case FtldslPackage.EXPRESSION__VALUE:
				return getValue();
			case FtldslPackage.EXPRESSION__NEXT:
				return getNext();
			case FtldslPackage.EXPRESSION__LOPERATOR:
				return getLoperator();
			case FtldslPackage.EXPRESSION__COPERATOR:
				return getCoperator();
			case FtldslPackage.EXPRESSION__INVOCATION:
				return getInvocation();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case FtldslPackage.EXPRESSION__VALUE:
				setValue(newValue);
				return;
			case FtldslPackage.EXPRESSION__NEXT:
				setNext((Expression)newValue);
				return;
			case FtldslPackage.EXPRESSION__LOPERATOR:
				setLoperator((LogicalOperator)newValue);
				return;
			case FtldslPackage.EXPRESSION__COPERATOR:
				setCoperator((ComparisonOperator)newValue);
				return;
			case FtldslPackage.EXPRESSION__INVOCATION:
				setInvocation((FunctionCall)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case FtldslPackage.EXPRESSION__VALUE:
				setValue(VALUE_EDEFAULT);
				return;
			case FtldslPackage.EXPRESSION__NEXT:
				setNext((Expression)null);
				return;
			case FtldslPackage.EXPRESSION__LOPERATOR:
				setLoperator(LOPERATOR_EDEFAULT);
				return;
			case FtldslPackage.EXPRESSION__COPERATOR:
				setCoperator(COPERATOR_EDEFAULT);
				return;
			case FtldslPackage.EXPRESSION__INVOCATION:
				setInvocation((FunctionCall)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case FtldslPackage.EXPRESSION__VALUE:
				return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
			case FtldslPackage.EXPRESSION__NEXT:
				return next != null;
			case FtldslPackage.EXPRESSION__LOPERATOR:
				return loperator != LOPERATOR_EDEFAULT;
			case FtldslPackage.EXPRESSION__COPERATOR:
				return coperator != COPERATOR_EDEFAULT;
			case FtldslPackage.EXPRESSION__INVOCATION:
				return invocation != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (value: ");
		result.append(value);
		result.append(", loperator: ");
		result.append(loperator);
		result.append(", coperator: ");
		result.append(coperator);
		result.append(')');
		return result.toString();
	}

} //ExpressionImpl
